<template>
    <div class="doubao-models">
        <editor-title
            title="模型选择"
            tips="指定生成模型(可让同样的提示词,不一样的效果)"
        />

        <div class="flex flex-wrap">
            <div
                v-for="item in config?.models"
                :key="item.key"
                class="model-item"
                :class="{ 'active': currentModel === item.key }"
                @click="currentModel = item.key"
            >
                <div
                    class="model-item-bg"
                    :style="{ 'background-image': `url(${appStore.toAbsoluteUrl(item.bg)})` }"
                >
                    <span class="text-mb">{{ item.name }}</span>
                    <span class="text-xs">{{ item.desc }}</span>
                </div>
            </div>
        </div>
    </div>
</template>

<script lang="ts" setup>
import { useVModels } from '@vueuse/core'
import { config } from '../../hooks/useDrawEffect'
import useAppStore  from '~/stores/app'
import editorTitle from '../common/editor-title.vue'

const emits = defineEmits<{
    (event: 'update:modelValue', value: string): void
}>()

const props = defineProps({
    // 绘图模型
    modelValue: {
        type: String,
        default: ''
    }
})

const appStore = useAppStore()

const { modelValue: currentModel } = useVModels(props, emits)
</script>

<style lang="scss" scoped>
.model-item {
    box-sizing: border-box;
    width: 158px;
    height: 64px;
    padding: 1px 2px;
    color: var(--color-white);
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 6px;
    &:first-child {
        margin-right: 4px;
    }
    &.active {
        border: 2px solid var(--el-color-primary);
    }
    .model-item-bg {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: 100%;
        background-size: cover;
    }
}
</style>
